package ink.xiaobaibai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ink.xiaobaibai.bo.SelectMonDeviceBo;
import ink.xiaobaibai.common.PageInfo;
import ink.xiaobaibai.dao.MonthlyfeeDeviceDao;
import ink.xiaobaibai.entity.MonthlyfeeDevice;
import ink.xiaobaibai.service.IMonthlyfeeDeviceService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xiaobaibai
 * @since 2021-05-30
 */
@Service
public class MonthlyfeeDeviceServiceImpl extends ServiceImpl<MonthlyfeeDeviceDao, MonthlyfeeDevice> implements IMonthlyfeeDeviceService {

    @Override
    public PageInfo<MonthlyfeeDevice> getDeviceList(SelectMonDeviceBo selectMonDeviceBo) {
        return new PageInfo<>(this.baseMapper.getDeviceList(selectMonDeviceBo), this.baseMapper.getCountByDeviceList(selectMonDeviceBo), selectMonDeviceBo.getPageSize());
    }

    @Override
    public boolean okCode(String code) {
        QueryWrapper<MonthlyfeeDevice> q1 = new QueryWrapper<>();
        q1.eq("device_code", code);
        return this.count(q1) == 0;
    }

    @Override
    public String getOxygenCodeByDeviceCode(String deviceCode) {
        return this.baseMapper.getOxygenCodeByDeviceCode(deviceCode);
    }

}
